{template 'web/_header'}
{template 'tabs'}

{if $operation == 'post'}
<div class="main">

    <form  {ife 'exhelper.temps' $item}action="" method="post"{/if} class="form-horizontal form" enctype="multipart/form-data" >

        <div class="panel panel-default">
            <div class="panel-heading">
                快递单发件人信息
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style='color:red'>*</span> 发件人</label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'exhelper.temps' $item}
                        <input type="text" name="sendername" class="form-control" value="{$item['sendername']}" />
                        <span class="help-block">如小张，xx商城</span>
                        {else}
                        <div class='form-control-static'>{$item['sendername']}</div>
                        {/if} 
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style='color:red'>*</span> 联系电话</label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'exhelper.temps' $item}
                        <input type="text" name="sendertel" class="form-control" value="{$item['sendertel']}" />
                        {else}
                        <div class='form-control-static'>{$item['sendertel']}</div>
                        {/if} 
                    </div>
                </div>
              
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style='color:red'>*</span> 发件地址</label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'exhelper.temps' $item}
                        <input type="text" name="senderaddress" class="form-control" value="{$item['senderaddress']}" />
                        {else}
                        <div class='form-control-static'>{$item['senderaddress']}</div>
                        {/if} 
                    </div>
                </div>
             <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">发件人签名</label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'exhelper.temps' $item}
                        <input type="text" name="sendersign" class="form-control" value="{$item['sendersign']}" />
                        <span class="help-block">如小张，小王</span>
                        {else}
                        <div class='form-control-static'>{$item['sendersign']}</div>
                        {/if} 
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否为默认模板</label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'exhelper.temps' $item}
                        <label class="radio-inline">
                            <input type="radio" name='isdefault' value="1" {if $item['isdefault']==1}checked{/if} /> 是
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name='isdefault' value="0" {if $item['isdefault']==0}checked{/if} /> 否
                        </label>
                      
                      {else} 
                       <div class='form-control-static'>{if $item['isdefault']==1}是{else}否{/if}</div>
                        {/if}
                      
                    </div>
                </div>
             <div class='panel-body'>
                <div class="form-group"></div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'exhelper.temps' $item}
                        <input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" onclick="return formcheck()" />
                        <input type="hidden" name="token" value="{$_W['token']}" />
                        {/if}
                        <input type="button" name="back" onclick='history.back()' {ifp 'exhelper.temps.add|exhelper.temps.edit'}style='margin-left:10px;'{/if} value="返回列表" class="btn btn-default col-lg-1" />
                    </div>
                </div>

            </div>
        </div>

    </form>
</div> 
<script language='javascript'>
    require(['util'], function (u) {
        $('#cp').each(function () {
            u.clip(this, $(this).text());
        });
    })
    $('form').submit(function () {
       if($(':input[name=sendername]').isEmpty()){
           Tip.focus($(':input[name=sendername]'),'请填写发件人!');
           return false;
       }
        if($(':input[name=sendertel]').isEmpty()){
           Tip.focus($(':input[name=sendertel]'),'请填写联系电话!');
           return false;
       }
        if($(':input[name=senderaddress]').isEmpty()){
           Tip.focus($(':input[name=senderaddress]'),'请填写发件地址!');
           return false;
       }
        return true;
    });
</script>
{elseif $operation == 'display'}
     <form action="" method="post">
<div class="panel panel-default">
    <div class="panel-body table-responsive">
        <table class="table table-hover">
            <thead class="navbar-inner">
                <tr>
                    <th style="width:30px;">ID</th>
                    <th>发件人</th>					
                    <th>联系电话</th>
                    <th>发件地址</th>
                    <th>是否默认</th>
                    <th >操作</th>
                </tr>
            </thead>
            <tbody>
                {loop $list $row}
                <tr>
                    <td>{$row['id']}</td>
                    <td>{$row['sendername']}</td>
                    <td>{$row['sendertel']}</td>
                    <td>{$row['senderaddress']}</td>
                       <td> 
                                    {if $row['isdefault']==1}
                                    <span class='label label-success'><i class='fa fa-check'></i></span>
                                    {/if}
                                </td>
                    <td style="text-align:left;">
                   
                        {ifp 'exhelper.temps.view|exhelper.temps.edit'}<a href="{php echo $this->createPluginWebUrl('exhelper/temps', array('op' => 'post', 'id' => $row['id']))}" class="btn btn-default btn-sm"  title="{ifp 'exhelper.temps.edit'}修改{else}查看{/if}"><i class="fa fa-edit"></i></a>{/if}
                        {ifp 'exhelper.temps.delete'}<a href="{php echo $this->createPluginWebUrl('exhelper/temps', array('op' => 'delete', 'id' => $row['id']))}"class="btn btn-default btn-sm" onclick="return confirm('确认删除此模板?')" title="删除"><i class="fa fa-times"></i></a>{/if}
                             {ifp 'exhelper.temps.setdefault'}
                        {if empty($row['isdefault'])}
                        <a href="{php echo $this->createPluginWebUrl('exhelper/temps', array('op' => 'setdefault', 'id' => $row['id']))}"class="btn btn-default btn-sm" onclick="return confirm('确认设置默认?')" title="设置默认"><i class="fa fa-check"></i></a>
                        {/if}
                        {/if}
                    </td>
                </tr>
                {/loop} 
                <tr>
                    <td colspan='6'>
                        {ifp 'exhelper.temps.add'}
                          <a class='btn btn-default' href="{php echo $this->createPluginWebUrl('exhelper/temps',array('op'=>'post'))}"><i class='fa fa-plus'></i> 添加快递单信息模板</a>
                          <input type="hidden" name="token" value="{$_W['token']}" />
                       {/if}
                    </td>
                </tr>
            </tbody>
        </table>
        {$pager}
    </div>
</div>
</form>
{/if}
{template 'common/footer'}

